package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Area;
import cn.wolfcode.trip.base.query.HotelQueryObject;
import cn.wolfcode.trip.base.service.IAreaService;
import cn.wolfcode.trip.base.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/areas")
public class AreaController {
    @Autowired
    private IAreaService areaService;
    @Autowired
    private IHotelService hotelService;

    //根据地区查询酒店
    @GetMapping("/{areaId}/hotels")
    @ResponseBody
    public Object getHotels(@ModelAttribute("qo") HotelQueryObject qo) {
        return hotelService.query(qo);
    }

    @GetMapping
    @ResponseBody
    public Object list() {
        //获取所有的地区
        return areaService.list();
    }
}
